When playing videos, video buffer queues (e.g., BufferQueue class in Java) are typically used during the process of playing videos. The video buffer queues externally provide producer interfaces that request buffers to put uncompressed video data and consumer interfaces that acquire buffers for display or further processing. The producer interface relates to an interface that de-queues emptied buffers to be filled with data and queues filled buffers. The consumer interface relates to an interface that accepts data for display or further processing. The BufferQueue includes a number of buffer units (or buffer blocks). The buffer units relate to units of memory. Empty buffer units within the BufferQueue are available to video data providers, e.g., video decoders. Filled buffer units are generated by filling the buffer units via a producer interface. In this context, filled buffer units include uncompressed video data. For consumers (e.g., threads or processes that handle video data), videos are rendered by reading the filled buffer units via a consumer interface. For example, various video rendering techniques can be differentiated based on different corresponding consumers. For example, the video rendering techniques include a SurfaceView rendering technique (e.g., implemented using a SurfaceView class in Android Java library) and a TextureView rendering technique (e.g., implemented using a TextureView class in Android Java Library). In the SurfaceView rendering technique, system graphic compositors (such as Android's SurfaceFlinger or Linux's Xserver/Weston) are the consumers. FIG. 1 is a diagram of an embodiment of a conventional process for rendering video using a SurfaceView rendering technique. A video decoder causes empty buffer units to exit from a video buffer queue (operation 1), fills the empty buffer units (operation 2), and causes filled buffer units to enter into the video buffer queue (operation 3). The system compositor obtains the filled buffer units from the video buffer queue (operation 4), renders video data from the filled buffer units (operation 5), and returns the empty buffer units to the video buffer queue (operation 6).
FIG. 2 is a diagram of an embodiment of a conventional process for rendering video using a TextureView rendering technique. In the TextureView rendering technique, similar initial operations are performed as in the SurfaceView rendering technique (operations 1-3). A rendering unit of a video-playing application obtains the filled buffer units from the video buffer queue (operation 4), renders video data from the filled buffer units (operation 5), and returns the empty buffer units to the video buffer queue (operation 6). The system compositor receives the rendered video data and presents the rendering result (operations 7 and 8). In the TextureView rendering technique, rendering units of video-playing applications are the consumers.
When video buffer queues (e.g., the BufferQueue objects) are created, the video buffer queues are bound to the consumers. A consumer could be a system graphic compositor or a rendering unit of a video-playing application. When switching the rendering technique during the process of playing a video, the current BufferQueue is always destroyed. Subsequently, a new BufferQueue is created, and the relevant technique for playing the video can be restored after the completion of the destruction of the current BufferQueue. During the switching of the rendering techniques, additional operations to create a new BufferQueue and allocate memory are performed. The performance of the additional operations affects execution efficiency and the video-playing technique result does not flow smoothly. A user can sense that the video is being interrupted and sticking in places as the video is being played. The user's experience is diminished as a result.